package com.uit.project.bustrip.main;

import com.uit.project.bustrip.R;
import com.uit.project.bustrip.R.layout;
import com.uit.project.bustrip.R.menu;
import com.uit.project.bustrip.activity.GenericActivity;
import com.uit.project.bustrip.appconfig.AppsConfig;
import com.uit.project.bustrip.bo.UserBOImpl;
import com.uit.project.bustrip.bointerface.UserBO;
import com.uit.project.bustrip.entity.User;
import com.uit.project.bustrip.valueobject.LoginInfo;

import android.os.Bundle;
import android.os.StrictMode;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class UserLogin extends GenericActivity<User, Integer> {
	private EditText phone;
	private EditText password;
	private Button btnLogin;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_user_login);
//		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
//				.permitAll().build();
//		StrictMode.setThreadPolicy(policy);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.uit.project.bustrip.activity.GenericActivity#initView()
	 */
	@Override
	public void initView() {
		phone = (EditText) findViewById(R.id.phone);
		password = (EditText) findViewById(R.id.password);
		btnLogin = (Button) findViewById(R.id.btnLogin);
		btnLogin.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
//				String txtPhone = phone.getText().toString();
//				String txtPass = password.getText().toString();
//				UserBO userBo = new UserBOImpl(getApplicationContext());
//				LoginInfo loginInfo = userBo.loginAsync(txtPhone, txtPass);
//				if (loginInfo.getResult() == AppsConfig.RESULT_SUCCESS) {
//					Toast.makeText(getApplicationContext(),
//							loginInfo.getMessage(), Toast.LENGTH_SHORT).show();
//				} else {
//					Toast.makeText(getApplicationContext(),
//							loginInfo.getMessage(), Toast.LENGTH_SHORT).show();
//				}
			}
		});
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.uit.project.bustrip.activity.GenericActivity#initData()
	 */
	@Override
	public void initData() {
		super.initData();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.user_login, menu);
		return true;
	}

}
